import instance from './instance'

export const registerApi = (username, password) =>
  instance.post('/auth/register', {
    username: username,
    password: password,
  })

export const loginApi = (username, password) =>
  instance.post('/auth/login', {
    username: username,
    password: password,
  })

export const getUser = (id, token) =>
  instance.get('/user/getUser', { headers: { Authorization: token }, params: { id: id } })

export const editUserinfo = (editUser, token) =>
  instance.post(
    '/user/edit',
    {
      id: editUser.id,
      username: editUser.username,
      password: editUser.password,
    },
    {
      headers: {
        Authorization: token,
      },
    },
  )

export const getAvatarApi = (username) => instance.get(`/user/avatar/${username}`)
